<%@ page contentType="text/html;charset=UTF-8"%>
<%@include file="module/common.jsp"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="description" content="cosmo云工厂">
<meta name="Keywords" content="cosmo,cosmo云工厂">
<title>cosmo云工厂</title>
<link href="${ctxStatic}/cloudfactory/css/basic.css" rel="stylesheet"
	type="text/css" />
<link href="${ctxStatic}/cloudfactory/css/main.css" rel="stylesheet"
	type="text/css" />
<link href="${ctxStatic}/cloudfactory/css/flex.css" rel="stylesheet"
	type="text/css" />
<link href="${ctxStatic}/cloudfactory/css/cloudFoundry.css"
	rel="stylesheet" type="text/css" />
<!–[if lt IE9]>
<script src="${ctxStatic}/cloudfactory/js/html5.js"></script>
<![endif]–>
</head>

<body>
	<div class="sys_warp">
		<!--header开始-->
		<jsp:include page="module/userCenterhead.jsp" flush="true" />

		<!--banner结束,主体开始-->
		 
		<div class="background">
			<div class="titleTextBackground absolute-left-center-top-self-center">
				<img class="titleTextBackgroundImg1"
					src="${ctxStatic}/cloudfactory/img/myFactory/background.png" alt=""> <img
					class="titleTextBackgroundImg2 absolute-self-center"
					src="${ctxStatic}/cloudfactory/img/myFactory/buliding.png" alt="">
				<p class="titleText1 absolute-self-top-center">
					MY<span>&ensp;FACTORY</span>
				</p>
				<p class="titleText2 absolute-self-top-center">我的工厂</p>
				<img class="titleTextLine" src="${ctxStatic}/cloudfactory/img/shoppingCart/line.png"
					alt="">
				<div class="rightMenu absolute-self-center">
					<div class="gouWuChe2">
						<img src="${ctxStatic}/cloudfactory/img/shoppingCart/gouWuChe2.png" alt="">
					</div>
					<div class="customer">
						<p>客服</p>
					</div>
					<div class="help">
						<p>帮助</p>
					</div>
				</div>
			</div>

			<div class="tableAllBox pb_40">
				<div class="navTextBox absolute-self-top-center">
					<p class="navText">
						<a href="user.html">首页</a>&ensp;>&ensp;<a href="myFactory.html">我的工厂</a>&ensp;>&ensp;<a
							href="#">添加工厂</a>
					</p>
				</div>
				<div id="tableTitle">
					<p class="tableTitleText">添加工厂</p>
				</div>
				<div class="inputContentBox">

					<form class="form" action="" method="post">
						<div class="InputBox width-100-height-auto">
							<p>企业号</p>
							<input class="input" id="inputCompany" type="text" value=""
								placeholder="" onfocus="isCompanyNumber()"
								onblur="companynumberonblur()">
							<div class="judgeInput"></div>
						</div>
						<div class="InputBox width-100-height-auto">
							<p>工厂名称</p>
							<input class="input" id="inputJob" type="text" value=""
								placeholder="" onfocus="isJob()" onblur="jobonblur()">
							<div class="judgeInput"></div>
						</div>
						<div class="InputBox width-100-height-auto">
							<p>联系人</p>
							<input class="input" id="inputName" type="text" value=""
								placeholder="" onfocus="isChinaName()" onblur="nameonblur()">
							<div class="judgeInput"></div>
						</div>
						<div class="InputBox width-100-height-auto">
							<p>联系方式</p>
							<input class="input" id="inputPhoneNumber" type="text" value=""
								placeholder="" onfocus="isPhone()" onblur="phoneonblur()"
								maxlength="11">
							<div class="judgeInput"></div>
						</div>
						<div class="InputBox width-100-height-auto">
							<p>手机号</p>
							<input class="input" id="inputPhoneNumber1" type="text" value=""
								placeholder="" onfocus="isPhone1()" onblur="phoneonblur1()"
								maxlength="11">
							<div class="judgeInput"></div>
						</div>
						<div class="InputBox width-100-height-auto">
							<p>邮箱</p>
							<input class="input" id="inputEmail" type="text" value=""
								placeholder="" onfocus="isEmail()" onblur="emailonblur()">
							<div class="judgeInput"></div>
						</div>
					</form>
					<div class="makeSureAdd">
						<a  onclick="submitbtn()" >
							<p>确认添加</p>
						</a>
					</div>
				</div>
			</div>


		</div>


		<!--主体结束,footer开始-->
		<jsp:include page="module/foot.jsp" flush="true" />
		<!--footer结束-->
	</div>
</body>
<script type="text/javascript"
	src="${ctxStatic}/cloudfactory/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript"
	src="${ctxStatic}/cloudfactory/js/main.js"></script>
<script>
	function submitbtn() {
		var reg = /^(((13[0-9]{1})|(15[0-9]{1})|(17[0-9])|(18[0-9]{1}))+\d{8})$/;
		var emalReg = /^([a-zA-Z0-9]*[-_.]?[a-zA-Z0-9]+)*@([a-zA-Z0-9]*[-_]?[a-zA-Z0-9]+)+[\\.][A-Za-z]{2,3}([\\.][A-Za-z]{2})?$/;
		
		var companyNo = encodeURI($("#inputCompany").val());
		var companyName = encodeURI($("#inputJob").val());
		var lankman = encodeURI($("#inputName").val());
		var lankWay = encodeURI($("#inputPhoneNumber").val());
		var mobile =encodeURI($("#inputPhoneNumber1").val());
		var mail = encodeURI($("#inputEmail").val());
		if (mobile.length != 11) {
			alert("请输入有效的手机号位数");
			return ;
		}
		var result = reg.test(mobile);
		if (!result) {
			alert("请输入有效的手机号");
			return ;
		}
		var result = emalReg.test(mail);
		if (!result) {
			alert("请输入正确的邮箱地址");
			return ;
		}
		$.ajax({
			//几个参数需要注意一下
			type : "POST",//方法类型
			dataType : "json",//预期服务器返回的数据类型
			url : "${ctx}/userCenter/saveFactory",//url
			data : {
				companyNo:companyNo,
				companyName:companyName,
				lankman:lankman,
				lankWay:lankWay,
				mobile:mobile,
				mail:mail
			},
			success : function(result) {
				debugger;
				if (result.success == "success") {
					
					alert("添加工厂成功");

					window.location.href = "${ctx}/userCenter/goMyFactory";
				} else {
					alert(result.success);
					return false;
				}
			},
			error : function(result) {
				alert("注册异常");
				return ;
			}
		});
		
		
		
	}
	$(function() {
		indexInit();
	});
</script>
</html>